<?php

declare(strict_types=1);

namespace App\Entity;

class OrderServiceImageEntity extends ABaseEntity
{
    public function __construct(OrderServiceImageModel $model)
    {
        $this->model = $model;
    }

    /**
     * 返回做单完成时上传的图片 url
     *
     * @return array
     */
    public static function getImagesByOrderId(int $orderId)
    {
        $collection = OrderServiceImageModel::where('order_id', $orderId)->get();
        if ($collection->isEmpty()) {
            return [];
        }

        return array_column($collection->toArray(), 'image');
    }

    public function getId(): int
    {
        return (int) $this->model->id;
    }

    public function getOrderId(): int
    {
        return (int) $this->model->order_id;
    }

    public function setOrderId(int $order_id): void
    {
        $this->model->order_id = $order_id;
    }

    public function getImage(): string
    {
        return $this->model->image;
    }

    public function setImage(string $image): void
    {
        $this->model->image = $image;
    }
}
